<?php

/**
 * Controller/ExportController.php
 */

namespace RHX\Controller;

use ZendService\LiveDocx\MailMerge;

class ExportController extends RHXController {

    public function ficheEmployeAction() {
	$locale		 = \Locale::getDefault();
	$timestamp	 = time();

	$intlTimeFormatter = new \IntlDateFormatter($locale, \IntlDateFormatter::NONE, \IntlDateFormatter::SHORT);

	$intlDateFormatter = new \IntlDateFormatter($locale, \IntlDateFormatter::LONG, \IntlDateFormatter::NONE);

	$mailMerge = new MailMerge();

	$mailMerge->setUsername('donatkamary@gmail.com')
		->setPassword('ondaground9')
		->setService(MailMerge::SERVICE_FREE);  // for LiveDocx Premium, use MailMerge::SERVICE_PREMIUM

	$mailMerge->setLocalTemplate('../../../data/tpl/template.docx');

	$mailMerge->assign('nom1', 'KAMARY')
		->assign('nom2', '')
		->assign('prenom', 'Donat')
		->assign('naissance', '02 juin 1986');

	$mailMerge->createDocument();

	$document = $mailMerge->retrieveDocument('pdf');

	file_put_contents('license-agreement-document.pdf', $document);

	unset($mailMerge);

	return new \Zend\View\Model\JsonModel(array());
    }

}

?>
